package com.example.demo.common;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * Created with IntelliJ IDEA.
 * Description: 统一异常处理
 * User: yyx
 * Date: 2023-11-06
 * Time: 21:19
 */

//开发阶段先省去此注解,需要暴露问题,而不是统一拦截问题
//@RestControllerAdvice
public class ExceptionAdvice {

    @ExceptionHandler(Exception.class)
    public ResultAjax doException(Exception e){
        //默认错误返回-1 状态码
        return ResultAjax.fail(-1,e.getMessage());
    }
}
